<?=$this->header()?>


    <?=$this->menu("forums")?>


    <h1><?=$this->message("label.header", _Forum::BUNDLE)?></h1>


    <? /* Breadcrums route & user info display */ ?>
    <?=$this->route(
        array(
            array(
                "name"=>$this->message("label.category.header", _Forum::BUNDLE),
                "href"=>"forum/category/list"
            ),
            $this->category($this->topicListForm->getId())
        ), // Route display
        $this->topicListForm,                           // ListForm (for topic info, see float right)
        $this->topics($this->topicListForm)->getRows()) // The total amount of topics
    ?>


    <? /* Show status messages */ ?>
    <?=$this->messages(_Core::BUNDLE)?>


    <? /* Show error messages */ ?>
    <?=$this->errors(null)?>


    <form id="<?=get_class($this->topicListForm)?>"
          method="post"
          action="forum/list"
          onsubmit="return confirmDelete('<?=$this->message("message.confirm.delete", _Core::BUNDLE)?>', this)">


        <? /* Show the Search & Filter Panel */ ?>
        <?=$this->panel(
            "forum/edit?topic->categoryId=".$this->topicListForm->getId(), // Add New URL
            $this->topicListForm, // ListForm
            array(                   // Filter fields
                TopicPeer::NAME=>$this->message("prompt.name", _Forum::BUNDLE),
                TopicPeer::BODY=>$this->message("prompt.body", _Forum::BUNDLE),
                TopicPeer::USERNAME=>$this->message("label.username", _Forum::BUNDLE),
                TopicPeer::MODIFIED_DATE=>$this->message("choose.modified", _Core::BUNDLE),
                TopicPeer::INSERT_DATE=>$this->message("choose.created", _Core::BUNDLE),
                TopicPeer::ACTIVE=>$this->message("choose.active", _Core::BUNDLE),
                TopicPeer::CLOSED=>$this->message("label.closed", _Forum::BUNDLE),
            ),
            false // No languages for this page.
        )?>


        <? /* Start output buffering in case there are no results */ ?>
        <?$this->start()?>


        <table class="list" cellspacing="0" cellpadding="0">
        <tr>
            <th class="checkbox"></th>
            <th>
                <?=$this->TH(
                    $this->topicListForm,                         // ListForm
                    TopicPeer::NAME,                              // Sort Field
                    $this->message("prompt.name", _Forum::BUNDLE) // Header Name
                )?>
            </th>
            <th class="narrow">
                <?=$this->TH(
                    $this->topicListForm,        // ListForm
                    TopicPeer::USERNAME,         // Sort Field
                    $this->message("label.username", _Forum::BUNDLE) // Header Name
                )?>
            </th>
            <th class="narrow">
                <?=$this->TH(
                    $this->topicListForm,           // ListForm
                    "count",                        // Sort Field
                    $this->message("label.replies", _Forum::BUNDLE) // Header Name
                )?>
            </th>
            <th class="narrow">
                <?=$this->TH(
                    $this->topicListForm,     // ListForm
                    TopicPeer::MODIFIED_DATE, // Sort Field
                    $this->message("choose.modified", _Core::BUNDLE)  // Header Name
                )?>
            </th>
            <th class="narrow">
                <?=$this->TH(
                    $this->topicListForm,     // ListForm
                    TopicPeer::INSERT_DATE,   // Sort Field
                    $this->message("choose.created", _Core::BUNDLE)  // Header Name
                )?>
            </th>
            <th class="narrow" title="<?=$this->message("title.active", _Core::BUNDLE)?>">
                <?=$this->TH(
                    $this->topicListForm,       // ListForm
                    TopicPeer::ACTIVE,          // Sort Field
                    $this->message("label.active", _Core::BUNDLE) // Header Name
                )?>
            </th>
            <th class="narrow" title="<?=$this->message("title.opened", _Forum::BUNDLE)?>">
                <?=$this->TH(
                    $this->topicListForm,       // ListForm
                    TopicPeer::CLOSED,          // Sort Field
                    "O" // Header Name
                )?>
            </th>
            <th class="buttons"></th>
        </tr>

        <? foreach($this->topics($this->topicListForm)->getItems() as $topic) { ?>

            <? /* Display the default language topic */ ?>
            <tr class="ctrl">
                <td class="checkbox">

                    <input type="checkbox"
                           name="items[]"
                           value="<?=$topic->getTopicId()?>"
                           <?=in_array($topic->getTopicId(), $this->topicListForm->getItems()) ? " checked=\"checked\"" : ""?> />

                </td>
                <td title="<?=htmlspecialchars($topic->getName())?>"><?=$this->truncateNicely($topic->getName(), 16, 26, "...")?></td>
                <td>
                    <a title="<?=$this->message("title.username", _Forum::BUNDLE)." ".$topic->getUsername()?>" href="mailto:<?=$topic->getUsername()?>">
                        <?=$this->truncateNicely($topic->getUsername(), 16, 18, "...")?>
                    </a>
                </td>
                <td title="<?=$this->message("title.replies", _Forum::BUNDLE)?>">
                    <a title="<?=$this->message("title.replies", _Forum::BUNDLE)?>" href="forum/reply/list?id=<?=$topic->getTopicId()?>">
                        <?=$topic->getCount()?>
                    </a>
                </td>
                <td title="<?=$this->message("title.modified", _Core::BUNDLE)?> <?=$topic->getModifiedDate(_Core::FORMAT_DATETIME)?>">
                    <?=$topic->getModifiedDate(_Core::FORMAT_DATE)?>
                </td>
                <td title="<?=$this->message("title.created", _Core::BUNDLE)?> <?=$topic->getInsertDate(_Core::FORMAT_DATETIME)?>">
                    <?=$topic->getInsertDate(_Core::FORMAT_DATE)?>
                </td>
                <td title="<?=$this->message("title.active", _Core::BUNDLE)?>">
                    <?=$this->message("label." . ($topic->getActive() ? "yes" : "no"), _Core::BUNDLE)?>
                </td>
                <td title="<?=$this->message("title.opened", _Forum::BUNDLE)?>">
                    <?=$this->message("label." . ($topic->getClosed() ? "no" : "yes"), _Core::BUNDLE)?>
                </td>
                <td class="buttons">

                    <input type="button"
                           onclick="to('forum/edit?topic->topicId=<?=$topic->getTopicId()?>')"
                           class="button"
                           value="<?=$this->message("button.edit", _Core::BUNDLE)?>" />

                    <input type="button"
                           onclick="del(<?=$topic->getTopicId()?>, '<?=get_class($this->topicListForm)?>')"
                           class="button"
                           value="<?=$this->message("button.delete", _Core::BUNDLE)?>" />
                </td>
            </tr>

        <? } ?>

        </table>


        <? /* Edit/Action Bar for checkboxed */ ?>
        <?=$this->edit(
            $this->topicListForm, // ListForm
            array(                // The actions
                "activate"=>$this->message("choose.activate", _Core::BUNDLE),
                "deactivate"=>$this->message("choose.deactivate", _Core::BUNDLE),
                "open"=>$this->message("label.open", _Forum::BUNDLE),
                "close"=>$this->message("label.close", _Forum::BUNDLE),
                "delete"=>$this->message("choose.delete", _Core::BUNDLE)
            )
        )?>


        <? /* End output buffering */ ?>
        <?$this->end(
            $this->topicListForm,                                          // ListForm
            "forum/edit?topic->categoryId=".$this->topicListForm->getId(), // Add New URL
            $this->topics($this->topicListForm)->getRows()                 // The total amount of topics
        )?>


    </form>

<?=$this->footer()?>